//解析主页面传入的参数属性值
let yy = getUrlParams(location.href)
console.log(yy);

let categoryid = yy.categoryid
let title= yy.category
console.log(title);
//请求数据
fetch(`http://chst.vip:1234/api/getproductlist?categoryid=${categoryid}`)
    .then((body) => body.json())
    .then((res) => {
        console.log(res);
        let html = "";
        let { result: data } = res;
        let a = ""
        a=`<a>${title}</a>`
        data.forEach((item) => {
            console.log(item);
            html += `
            <li productid="${item.productId}" categoryid="${item.categoryId}">
            <div class="img">${item.productImg}</div>
            <div class="name">
            <h4>${item.productName}</h4>
            <div class="price">${item.productPrice}</div>
            <span>${item.productQuote}</span>
            <i>${item.productCom}</i>
            </div>
            </a>
            </li>`
        })
        document.querySelector("#nav-vv ul").innerHTML += html;
        $('#subNav').append(a)
    })
    $("#nav-vv ul").on("click","li",function(){
        console.log(this);
        let categoryid = $(this).attr("categoryid")
        console.log(categoryid);

        let productid = $(this).attr("productid")
       

        location.href=`../pages/bijiajia.html?categoryid=${categoryid}&productid=${productid}`
    })


